import request from '@/utils/request';

export async function getErrorReportByPage(params: any) {
  return request('/api/product/getErrorReportByPage', {
    method: 'POST',
    data: params,
  });
}

export async function addErrorReport(params: any) {
  return request('/api/product/addErrorReport', {
    method: 'POST',
    data: params,
  });
}

export async function updateErrorReport(params: any) {
  return request('/api/product/updateErrorReport', {
    method: 'POST',
    data: params,
  });
}

export async function delErrorReport(params: any) {
  return request('/api/product/delErrorReport', {
    method: 'POST',
    data: params,
  });
}
/**
 * @description: 异常处理完成
 * @param {any} params
 * @return {*}
 */
export async function finishErrorReport(params: any) {
  return request('/api/product/finishErrorReport', {
    method: 'POST',
    data: params,
  });
}

// 导出全部
export async function exportErrorReport(params: any) {
  return request('/api/product/exportErrorReport', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

// 根据状态导出
export async function exportErrorReportByHandleStatus(params: any) {
  return request('/api/product/exportErrorReportByHandleStatus', {
    method: 'POST',
    params: {
      handleStatus: params,
    },
    responseType: 'blob',
  });
}

// 获取团队成员
export async function getTeamMember(params: any) {
  return request('/api/product/getTeamMember', {
    method: 'POST',
    params: {
      workOrderInfoId: params,
    },
  });
}

// 异常处理
export async function deliverErrorReport(params: any) {
  return request('/api/product/deliverErrorReport', {
    method: 'POST',
    data: params,
  });
}

// 获取当前用户名
export async function viewBaseInfo(params: any) {
  return request('/api/user/viewBaseInfo', {
    method: 'POST',
    data: params,
  });
}

// 异常附件下载
export async function downloadErrorReportFile(para: any) {
  return request('/api/product/downloadErrorReportFile', {
    method: 'GET',
    responseType: 'blob',
    params: {
      errorReportId: para.errorReportId,
    },
  });
}

// 获取异常优先级
export async function getAllErrorPriority(params: any) {
  return request('/api/product/getAllErrorPriority', {
    method: 'POST',
    data: params,
  });
}

// 获取异常类型
export async function getAllErrorType(params: any) {
  return request('/api/product/getAllErrorType', {
    method: 'POST',
    data: params,
  });
}

// 获取工单编号
export async function getWorkOrderInforList(params: any) {
  return request('/api/product/getWorkOrderInforList', {
    method: 'POST',
    data: params,
  });
}

// 新增异常
export async function addErrorReport2(para: any) {
  return request('/api/product/addErrorReport2', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    params: {
      Wo: para.Wo,
      deadLine: para.deadLine,
      errorDes: para.errorDes,
      errorType: para.errorType,
      handlingMan: para.handlingMan,
      operator: para.operator,
      priority: para.priority,
      taskId: para.taskId,
      workOrderInforId: para.workOrderInforId,
      projectName: para.projectName,
      workHour: para.workHour,
    },
  });
}

//查找异常处理人
export async function getErrorReportMembers(params: any) {
  return request('/api/product/getErrorReportMembers', {
    method: 'POST',
    data: params,
  });
}

//获取文件url接口
export async function getErrorPreviewUrl(params: any) {
  return request('/api/product/getErrorPreviewUrl', {
    method: 'POST',
    data: params,
  });
}

//异常处理新增附件
export async function uploadErrorReportFilelnfo(params: any) {
  return request('/api/product/uploadErrorReportFilelnfo', {
    method: 'POST',
    data: params,
  });
}

// 项目下拉框（所有项目）
export async function getProjectNameAndCodeSimp(params: any) {
  return request('/api/project/getProjectNameAndCodeSimp', {
    method: 'POST',
    data: params,
  });
}

// 工单下拉框（根据项目id）
export async function getWorkOrderInforListByInfoId(para: any) {
  return request('/api/product/getWorkOrderInforListByInfoId', {
    method: 'POST',
    params: {
      infoId: para.infoId,
    },
  });
}

// 获取工单编号
export async function getWorkOrderInforByWo(para: any) {
  return request('/api/product/getWorkOrderInforByWo', {
    method: 'POST',
    params: {
      wo: para.wo,
    },
  });
}

export default {
  getErrorReportByPage,
  addErrorReport,
  updateErrorReport,
  delErrorReport,
  exportErrorReport,
  getErrorReportMembers,
  getErrorPreviewUrl,
  uploadErrorReportFilelnfo,
  finishErrorReport,
};
